package autokeyboard.handler;

import javax.swing.JComboBox;

@SuppressWarnings({"rawtypes"})
public class ControlsDialogEvent
{
	/**
	 * This method is check whether one of your comboBox has the same index
	 */
	public void isSameIndexComponent(JComboBox cbbStartKey, JComboBox cbbPauseKey, JComboBox cbbStopKey) {
		if (cbbStartKey.getSelectedIndex() == cbbPauseKey.getSelectedIndex()) {
			setDefaultSelectedIndex(cbbStartKey, cbbPauseKey, cbbStopKey);
		}
		else if (cbbStartKey.getSelectedIndex() == cbbStopKey.getSelectedIndex()) {
			setDefaultSelectedIndex(cbbStartKey, cbbPauseKey, cbbStopKey);
		}
		else if (cbbPauseKey.getSelectedIndex() == cbbStopKey.getSelectedIndex()) {
			setDefaultSelectedIndex(cbbStartKey, cbbPauseKey, cbbStopKey);
		}
	}

	/**
	 * This method will reset all your comboBox selected index to default
	 * 
	 * @param cbbStartKey
	 * @param cbbPauseKey
	 * @param cbbStopKey
	 */
	private void setDefaultSelectedIndex(JComboBox cbbStartKey, JComboBox cbbPauseKey, JComboBox cbbStopKey) {
		cbbStartKey.setSelectedIndex(0);
		cbbPauseKey.setSelectedIndex(1);
		cbbStopKey.setSelectedIndex(2);
	}
}
